package cn.tedu.ivos2.dict.controller;

import cn.tedu.ivos2.base.response.JsonResult;
import cn.tedu.ivos2.dict.pojo.dto.DictQuery;
import cn.tedu.ivos2.dict.pojo.dto.DictSaveParam;
import cn.tedu.ivos2.dict.pojo.vo.DictVO;
import cn.tedu.ivos2.dict.service.DictService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/v1/dict/")
@Slf4j
public class DictController {
   @Autowired
   DictService dictService;

   @GetMapping("select")
   public JsonResult selectDirt(DictQuery dictQuery){
      log.debug("查询字典：{}",dictQuery);
      List<DictVO> list= dictService.selectDirt(dictQuery);
      return JsonResult.ok(list);
   }

   @PostMapping("save")
   public JsonResult saveDirt(DictSaveParam dictSaveParam){
      log.debug("保存新增字典：{}",dictSaveParam);
      dictService.saveDirt(dictSaveParam);
      return JsonResult.ok();
   }

   @PostMapping("delete/{id}")
   public JsonResult deleteDirt(@PathVariable Long id){
      log.debug("删除字典：{}",id);
      dictService.deleteDirt(id);
      return JsonResult.ok();
   }
}
